#include <vector>
#include <iostream>

using std::cout;
using std::endl;
using std::vector;

int main(void) {
    vector <int> vec;
    cout << "vector initial size: " << vec.size() << endl;
    cout << "vector initial capacity: " << vec.capacity() << endl;
    cout << "Now manual reserve vec capacity to 10" << endl;
    vec.reserve(10);
    cout << "vector size: " << vec.size() << endl;
    cout << "vector capacity: " << vec.capacity() << endl;
    cout << "Now manual resize vec size to 10" << endl;
    vec.resize(10);
    cout << "vector size: " << vec.size() << endl;
    cout << "vector capacity: " << vec.capacity() << endl;
    cout << "push 1 to vec(will at index 10)" << endl;
    vec.push_back(1);
    cout << "vector size: " << vec.size() << endl;
    cout << "vector capacity: " << vec.capacity() << endl;
    
    vector<int>::iterator vit = vec.begin();
    while(vit != vec.end()) {
        cout << "value of *vit: " << *vit << endl;
            //*vit: 这里*运算符被重载了
        vit++;
    } 
    vector<int> v2(2);
    cout << "v2(2) initial size: " << v2.size() << endl;
    cout << "v2(2) initial capacity: " << v2.capacity() << endl;
    return 0;
}
